from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import QIcon
import sys


def on_delete_click():
    text, confirm = QInputDialog.getText(w,
                                         "请输入", "请输入用户名")
    print("text: ", text, confirm)


if __name__ == '__main__':
    # 1.创建应用程序
    app = QApplication(sys.argv)

    # 2.创建窗口
    w = QWidget()

    w.resize(400, 300)

    # 修改窗口标题
    w.setWindowTitle('对话框')

    button = QPushButton("创建")
    button.clicked.connect(on_delete_click)
    button.setParent(w)

    # 3.显示窗口
    w.show()

    # 4.等待窗口停止
    sys.exit(app.exec())
